package com.itjiange;

/**
 * 已经投放钱币的状态
 *
 * @author ItJianGe
 * @data 2024/8/20 17:18
 */
public class HasCoinStatus implements Status {

    private GumballMachine gumballMachine;

    public HasCoinStatus(GumballMachine gumballMachine) {
        this.gumballMachine = gumballMachine;
    }

    @Override
    public void insertCoin() {
        System.out.println("已经投入钱币，无需重复投入");
    }

    @Override
    public void undoCoin() {
        System.out.println("退款成功");
        // 修改为未投币的状态
        gumballMachine.setStatus(gumballMachine.getNoCoinStatus());
    }

    @Override
    public void turnCrank() {
        System.out.println("正在出货中请稍等");
        gumballMachine.setStatus(gumballMachine.getSoleChewStatus());
    }

    @Override
    public void dispense() {
        System.out.println("发放一个口香糖");
    }
}
